'use strict';

/**
 * @param {Egg.Application} app - egg application
 */
module.exports = app => {
  const { router, controller } = app;
  // RESTful 风格的 URL 定义
  router.resources('posts', '/api/posts', controller.posts);

  // 针对单个路由生效 使用中间件
  const gzip = app.middleware.gzip({ threshold: 1024 });

  // router.get('/', gzip, controller.home.index);

  app.router.redirect('/', '/home/index', 302);
  router.get('index', '/home/index', controller.home.index);

  router.get('/news', controller.news.list);

  router.get(/^\/package\/([\w-.]+\/[\w-.]+)$/, app.controller.package.detail);

  router.get('/search', app.middlewares.uppercase(), controller.search.index);

  app.router.get('/user/:id', app.controller.user.info);
  app.router.get('/user1', app.controller.user.info1);
};
